package com.jeesite.modules.kj.utils;

import com.jeesite.common.utils.SpringUtils;
import com.jeesite.modules.kj.entity.KjLike;
import com.jeesite.modules.kj.service.KjLikeService;
import com.jeesite.modules.kj.service.KjSkillService;

/**
 * 点赞工具类
 */
public class LikesUtil {
    /*
     * 静态内部类，延迟加载，懒汉式，线程安全的单例模式
     */
    private static final class Static {
        private static KjLikeService kjLikeService = SpringUtils.getBean(KjLikeService.class);
    }


    public static String getIsLike(String relationId, String memberId){
        KjLike where = new KjLike();
        where.setRelationId(relationId);
        where.setMemberId(memberId);
        long count = Static.kjLikeService.findCount(where);
        return count > 0 ? "1" : "0";
    }

    public static long getLikesCount(String relationId){
        KjLike where = new KjLike();
        where.setRelationId(relationId);
        long count = Static.kjLikeService.findCount(where);
        return count;
    }

}
